/*
 * @Author: 黄宇/Hyuishine
 * @Date: 2022-05-05 11:24:11
 * @LastEditors: 黄宇/Hyuishine
 * @LastEditTime: 2024-05-14 15:02:23
 * @Description:
 * @Email: hyuishine@gmail.com
 * @Company: 3xData
 * @youWant: add you want
 */
import App from "./App";

//! 全局组件

// 导航栏
import actionBar from "@/components/actionBar/index.vue";
import "@/components/actionBar/styles.scss";
Vue.component("actionBar", actionBar);

// 消息toast 通知
import toast from "./components/toast/index.vue";
Vue.component("toast", toast);

//是否显示加载中 的方法 调用store中的mutations方法
function showToast(config) {
  store.commit("switch_toast", config);
}
//也挂在到原型链上 方便在每个页面中  使用 this.$showToast()  去显示加载中
Vue.prototype.$showToast = showToast;

// 全局暂无数据视图组件
import nodata from "@/components/nodata/index.vue";
Vue.component("no-data", nodata);

//! vue 组件

// store
import store from "./store/index.js";
Vue.prototype.$store = store;

// 后台链接
import { baseImgUrl, baseApiUrl } from "./config.js";
// #ifdef H5
// import VConsole from "vconsole";
// const vconsole = new VConsole();
// Vue.prototype.$vconsole = vconsole;
// #endif

Vue.prototype.$imgApiUrl = baseImgUrl;
Vue.prototype.$baseApiUrl = baseApiUrl;

// 事件总线
Vue.prototype.$EVENT_BUS = new Vue();

// 字典获取 全局方法
Vue.prototype.$getDict = (type) =>
  new Promise(async (resolve, reject) => {
    const r = await store.dispatch("get_dict", {
      type: type,
    });
    const { code, data } = r;
    if (code == 200) {
      resolve(data);
    } else {
      reject(r);
    }
  });

// #ifndef VUE3
import Vue from "vue";
Vue.config.productionTip = false;
App.mpType = "app";
const app = new Vue({
  store,
  ...App,
});
app.$mount();
// #endif

// #ifdef VUE3
import { createSSRApp } from "vue";
export function createApp() {
  const app = createSSRApp(App);
  return {
    app,
  };
}
// #endif
